package com.java.controller.admin;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.java.pojo.vo.BorrowerAproveVo;
import com.java.pojo.vo.BorrowerDetailVo;
import com.java.pojo.vo.BorrowerInfoVo;
import com.java.pojo.vo.BorrowerVo;
import com.java.result.Result;
import com.java.service.BorrowerService;
import com.java.utils.JwtUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 借款人 前端控制器
 * </p>
 *
 * @author Helen
 * @since 2021-07-08
 */
@Api("账户信息")
@RestController
@RequestMapping("/admin/core/borrower")
public class AdminBorrowerController {

    @Resource
    private BorrowerService borrowerService;

    @ApiOperation("获取借款人分页列表")
    @GetMapping("/list/{pageNum}/{pageSize}")
    public Result listPage(@PathVariable Integer pageNum,@PathVariable Integer pageSize,@RequestParam String keywords){
       IPage page =  borrowerService.selectPage(pageNum,pageSize,keywords);
       return Result.ok(page);
    }

    @ApiOperation("获取借款人详情")
    @GetMapping("/borrowerDetail/{userId}")
    public Result getBorrowerDetail(@PathVariable Long userId){
        BorrowerDetailVo borrowerDetail = borrowerService.getBorrowerDetail(userId);
        return Result.ok(borrowerDetail);
    }

    @ApiOperation("设置借款人审批状态")
    @PostMapping("/approve")
    public Result borrowerApprove(@RequestBody BorrowerAproveVo borrowerAproveVo){
        borrowerService.approve(borrowerAproveVo);
        return Result.ok();
    }

    @ApiOperation("借款信息")
    @GetMapping("/show/{id}")
    public Result show(@PathVariable Long id){
        Map<String,Object> map = borrowerService.show(id);
        return Result.ok(map);
    }
}

